package org.dromara.job.snailjob;

import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import lombok.RequiredArgsConstructor;
import org.dromara.oce.mapper.OceAdvertiserEverydayCostMapper;
import org.dromara.oce.mapper.OceAdvertiserReferralRelationMapper;
import org.dromara.oce.service.OceTemplateTaskService;
import org.springframework.stereotype.Component;

/**
 * 创建广告任务
 * @author opensnail
 * @date 2024-05-17
 */
@Component
@JobExecutor(name = "promotionJob")
@RequiredArgsConstructor
public class PromotionJobExecutor {

    private final OceAdvertiserReferralRelationMapper referralRelationMapper;
    private final OceAdvertiserEverydayCostMapper oceAdvertiserEverydayCostMapper;
    private final OceTemplateTaskService oceTemplateTaskService;

    public ExecuteResult jobExecute(JobArgs jobArgs) {
        SnailJobLog.REMOTE.info("定时执行创建广告任务. jobArgs:{}", JsonUtil.toJsonString(jobArgs));

        oceTemplateTaskService.executeTask();

        return ExecuteResult.success("定时执行创建广告任务成功!");
    }
}
